home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / idl / nsIServerSocket.idl < prev    next >
Text File  |  2006-05-08  |  7KB  |  174 lines

  1. /* vim:set ts=4 sw=4 et cindent: */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is Mozilla.
  16.  *
  17.  * The Initial Developer of the Original Code is IBM Corporation.
  18.  * Portions created by IBM Corporation are Copyright (C) 2003
  19.  * IBM Corporation. All Rights Reserved.
  20.  *
  21.  * Contributor(s):
  22.  *   Darin Fisher <darin@meer.net>
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #include "nsISupports.idl"
  39.  
  40. interface nsIServerSocketListener;
  41. interface nsISocketTransport;
  42.  
  43. native PRNetAddr(union PRNetAddr);
  44. [ptr] native PRNetAddrPtr(union PRNetAddr);
  45.  
  46. /**
  47.  * nsIServerSocket
  48.  *
  49.  * An interface to a server socket that can accept incoming connections.
  50.  */
  51. [scriptable, uuid(a5b64be0-d563-46bb-ae95-132e46fcd42f)]
  52. interface nsIServerSocket : nsISupports
  53. {
  54.     /**
  55.      * init
  56.      *
  57.      * This method initializes a server socket.
  58.      *
  59.      * @param aPort
  60.      *        The port of the server socket.  Pass -1 to indicate no preference,
  61.      *        and a port will be selected automatically.
  62.      * @param aLoopbackOnly
  63.      *        If true, the server socket will only respond to connections on the
  64.      *        local loopback interface.  Otherwise, it will accept connections
  65.      *        from any interface.  To specify a particular network interface,
  66.      *        use initWithAddress.
  67.      * @param aBackLog
  68.      *        The maximum length the queue of pending connections may grow to.
  69.      *        This parameter may be silently limited by the operating system.
  70.      *        Pass -1 to use the default value.
  71.      */
  72.     void init(in long aPort, in boolean aLoopbackOnly, in long aBackLog);
  73.  
  74.     /**
  75.      * initWithAddress
  76.      *
  77.      * This method initializes a server socket, and binds it to a particular
  78.      * local address (and hence a particular local network interface).
  79.      *
  80.      * @param aAddr
  81.      *        The address to which this server socket should be bound.
  82.      * @param aBackLog
  83.      *        The maximum length the queue of pending connections may grow to.
  84.      *        This parameter may be silently limited by the operating system.
  85.      *        Pass -1 to use the default value.
  86.      */
  87.     [noscript] void initWithAddress([const] in PRNetAddrPtr aAddr, in long aBackLog);
  88.  
  89.     /**
  90.      * close
  91.      *
  92.      * This method closes a server socket.  This does not affect already
  93.      * connected client sockets (i.e., the nsISocketTransport instances
  94.      * created from this server socket).  This will cause the onStopListening
  95.      * event to asynchronously fire with a status of NS_BINDING_ABORTED.
  96.      */
  97.     void close();
  98.  
  99.     /**
  100.      * asyncListen
  101.      *
  102.      * This method puts the server socket in the listening state.  It will
  103.      * asynchronously listen for and accept client connections.  The listener
  104.      * will be notified once for each client connection that is accepted.  The
  105.      * listener's onSocketAccepted method will be called on the same thread
  106.      * that called asyncListen (the calling thread must have a nsIEventTarget).
  107.      *
  108.      * The listener will be passed a reference to an already connected socket
  109.      * transport (nsISocketTransport).  See below for more details.
  110.      *
  111.      * @param aListener
  112.      *        The listener to be notified when client connections are accepted.
  113.      */
  114.     void asyncListen(in nsIServerSocketListener aListener);
  115.  
  116.     /**
  117.      * Returns the port of this server socket.
  118.      */
  119.     readonly attribute long port;
  120.  
  121.     /**
  122.      * Returns the address to which this server socket is bound.  Since a
  123.      * server socket may be bound to multiple network devices, this address
  124.      * may not necessarily be specific to a single network device.  In the
  125.      * case of an IP socket, the IP address field would be zerod out to
  126.      * indicate a server socket bound to all network devices.  Therefore,
  127.      * this method cannot be used to determine the IP address of the local
  128.      * system.  See nsIDNSService::myHostName if this is what you need.
  129.      */
  130.     [noscript] PRNetAddr getAddress();
  131. };
  132.  
  133. /**
  134.  * nsIServerSocketListener
  135.  *
  136.  * This interface is notified whenever a server socket accepts a new connection.
  137.  * The transport is in the connected state, and read/write streams can be opened
  138.  * using the normal nsITransport API.  The address of the client can be found by
  139.  * calling the nsISocketTransport::GetAddress method or by inspecting
  140.  * nsISocketTransport::GetHost, which returns a string representation of the
  141.  * client's IP address (NOTE: this may be an IPv4 or IPv6 string literal).
  142.  */
  143. [scriptable, uuid(836d98ec-fee2-4bde-b609-abd5e966eabd)]
  144. interface nsIServerSocketListener : nsISupports
  145. {
  146.     /**
  147.      * onSocketAccepted
  148.      *
  149.      * This method is called when a client connection is accepted.
  150.      *
  151.      * @param aServ
  152.      *        The server socket.
  153.      * @param aTransport
  154.      *        The connected socket transport.
  155.      */
  156.     void onSocketAccepted(in nsIServerSocket aServ,
  157.                           in nsISocketTransport aTransport);
  158.  
  159.     /**
  160.      * onStopListening
  161.      *
  162.      * This method is called when the listening socket stops for some reason.
  163.      * The server socket is effectively dead after this notification.
  164.      *
  165.      * @param aServ
  166.      *        The server socket.
  167.      * @param aStatus
  168.      *        The reason why the server socket stopped listening.  If the
  169.      *        server socket was manually closed, then this value will be
  170.      *        NS_BINDING_ABORTED.
  171.      */
  172.     void onStopListening(in nsIServerSocket aServ, in nsresult aStatus);
  173. };
  174.